function [residual, g1, g2] = endog_baseline_static(y, x, params)
%
% Status : Computes static model for Dynare
%
% Inputs : 
%   y         [M_.endo_nbr by 1] double    vector of endogenous variables in declaration order
%   x         [M_.exo_nbr by 1] double     vector of exogenous variables in declaration order
%   params    [M_.param_nbr by 1] double   vector of parameter values in declaration order
%
% Outputs:
%   residual  [M_.endo_nbr by 1] double    vector of residuals of the static model equations 
%                                          in order of declaration of the equations
%   g1        [M_.endo_nbr by M_.endo_nbr] double    Jacobian matrix of the static model equations;
%                                                    columns: equations in order of declaration
%                                                    rows: variables in declaration order
%   g2        [M_.endo_nbr by (M_.endo_nbr)^2] double   Hessian matrix of the static model equations;
%                                                       columns: equations in order of declaration
%                                                       rows: variables in declaration order
%
%
% Warning : this file is generated automatically by Dynare
%           from model file (.mod)

residual = zeros( 79, 1);

%
% Model equations
%

T37 = params(11)*exp(y(34))*exp(y(2))^(1-params(8))*exp(y(9))^params(8);
T64 = exp(y(1))*exp(y(20))/exp(y(20));
T80 = 1/params(6);
T87 = T80*1/exp(y(22))*exp(y(10));
T92 = exp(y(9))/exp(y(2));
T104 = exp(y(1))*exp(y(9))/exp(y(9));
T120 = exp(y(12))*params(7)*params(31)*params(30)*exp(y(9))^params(17);
T135 = exp(y(15))/exp(y(1));
T142 = exp(y(14))^(1-params(2));
T163 = exp(y(1))^(-1);
T169 = exp(y(11))-exp(y(11))*params(43)/exp(y(1));
T181 = (params(6)-1)/params(6);
T183 = (1-params(2))*1/exp(y(22))*T181;
T185 = T183*exp(y(10))/exp(y(14));
T195 = exp(y(1))*exp(y(17))/exp(y(17));
T209 = params(2)*exp(y(10))*exp(y(1))*(params(6)-1)/(params(6)*exp(y(22))*exp(y(15)));
T217 = params(14)/2;
T226 = params(15)/2;
T234 = params(16)/2;
T242 = exp(y(23));
T253 = T242^params(37)*params(36)^(1-params(37));
T271 = T242*exp(y(38))/(exp(y(38))-1)*exp(y(25))/exp(y(26));
T281 = params(36)^((1-params(37))*(-exp(y(38))));
T282 = params(1)*params(26)*T242^(params(37)*(-exp(y(38))))*T281;
T283 = T242^exp(y(38));
T293 = params(36)^((1-exp(y(38)))*(1-params(37)));
T294 = params(1)*params(26)*T242^((1-exp(y(38)))*params(37))*T293;
T295 = T242^(exp(y(38))-1);
T309 = exp(y(27))^params(24);
T312 = (T242/params(36))^params(22);
T320 = exp(y(10))*exp(y(41))^params(25)/exp(y(60));
T326 = params(1)*params(32)^(-1);
T327 = params(36)*T312*T320^params(23)/T326;
T344 = T242^(-1);
T352 = T242^params(29)*params(36)^(1-params(29));
T365 = params(28)/(params(28)-1)*exp(y(44))/exp(y(45));
T384 = exp(y(43))/exp(y(42));
T387 = exp(y(14))*T384^(-params(28));
T464 = params(11)*exp(y(34))*exp(y(51))^(1-params(8))*exp(y(53))^params(8);
T491 = exp(y(49))*exp(y(72))/exp(y(72));
T510 = exp(y(60))*T80*1/exp(y(61));
T515 = exp(y(53))/exp(y(51));
T520 = exp(y(35))*T515^(1-params(8))*exp(y(71));
T525 = exp(y(49))*exp(y(53))/exp(y(53));
T536 = exp(y(57))*params(7)*params(31)*params(30)*exp(y(53))^params(17);
T548 = exp(y(54))/exp(y(49));
T553 = exp(y(64))^(1-params(2));
T554 = exp(y(40))*T548^params(2)*T553;
T578 = exp(y(65))-params(43)*exp(y(65))/exp(y(49));
T591 = (1-params(2))*T181*1/exp(y(61))*exp(y(60))/exp(y(64));
T599 = exp(y(49))*exp(y(66))/exp(y(66));
T613 = params(2)*exp(y(60))*(params(6)-1)*exp(y(49))/(params(6)*exp(y(61))*exp(y(54)));
T649 = params(28)/(params(28)-1)*params(5)*exp(y(64))^params(3);
T654 = exp(y(1))*exp(y(41))/exp(y(49));
T692 = (-(exp(y(1))*exp(y(15))))/(exp(y(1))*exp(y(1)));
T699 = exp(y(1))*getPowerDeriv(exp(y(1)),(-1),1);
T708 = getPowerDeriv(exp(y(1))*exp(y(11))-exp(y(11))*params(43),(-1),1);
T745 = getPowerDeriv(params(32)*exp(y(42))*T163*T344*T352,1-params(28),1);
T840 = getPowerDeriv(T327,1-params(24),1);
T857 = (-(exp(y(12))*exp(y(27))/T242*exp(y(36))));
T888 = (-(exp(y(12))*(-(params(2)*exp(y(10))*exp(y(1))*(params(6)-1)*params(6)*exp(y(22))*exp(y(15))))/(params(6)*exp(y(22))*exp(y(15))*params(6)*exp(y(22))*exp(y(15)))));
T897 = (-(T92^(1-params(8))*exp(y(35))*exp(y(19))));
T903 = (-exp(y(22)))/(exp(y(22))*exp(y(22)));
T968 = params(36)^(1-params(29))*T242*getPowerDeriv(T242,params(29),1);
T1018 = (-(exp(y(36))*exp(y(57))*exp(y(69))/params(36)));
T1136 = (-(exp(y(49))*exp(y(54))))/(exp(y(49))*exp(y(49)));
T1152 = getPowerDeriv(exp(y(49))*exp(y(65))-params(43)*exp(y(65)),(-1),1);
T1244 = (-(exp(y(57))*(-(params(2)*exp(y(60))*(params(6)-1)*exp(y(49))*params(6)*exp(y(61))*exp(y(54))))/(params(6)*exp(y(61))*exp(y(54))*params(6)*exp(y(61))*exp(y(54)))));
lhs =exp(y(1));
rhs =params(7)+params(7)*exp(y(3))*(exp(y(2))-1);
residual(1)= lhs-rhs;
lhs =exp(y(1))*exp(y(2));
rhs =params(7)*exp(y(2))+exp(y(4));
residual(2)= lhs-rhs;
lhs =exp(y(4));
rhs =T37;
residual(3)= lhs-rhs;
lhs =exp(y(6));
rhs =(-exp(y(5)))*exp(y(18))+params(7)*exp(y(12))*(exp(y(3))*exp(y(7))+exp(y(6))*(1-exp(y(3))));
residual(4)= lhs-rhs;
lhs =exp(y(18));
rhs =1+y(30)+T64*y(31)-y(31)*exp(y(12))*T64^2;
residual(5)= lhs-rhs;
lhs =exp(y(7));
rhs =exp(y(8))+params(7)*exp(y(12))*exp(y(7));
residual(6)= lhs-rhs;
lhs =exp(y(8));
rhs =T87;
residual(7)= lhs-rhs;
lhs =exp(y(34))*params(11)*exp(y(6))*exp(y(12));
rhs =T92^(1-params(8))*exp(y(35))*exp(y(19));
residual(8)= lhs-rhs;
lhs =exp(y(19));
rhs =1+y(32)+T104*y(33)-y(33)*exp(y(12))*T104^2;
residual(9)= lhs-rhs;
lhs =T120*(exp(y(7))-exp(y(6)));
rhs =exp(y(18))*exp(y(5))^(1-params(31));
residual(10)= lhs-rhs;
lhs =exp(y(3));
rhs =params(30)*exp(y(9))^params(17)*exp(y(5))^params(31);
residual(11)= lhs-rhs;
lhs =exp(y(10));
rhs =exp(y(40))*T135^params(2)*T142;
residual(12)= lhs-rhs;
lhs =exp(y(10));
rhs =exp(y(11))+(1+y(28))*exp(y(17))+(1+y(30))*exp(y(20))+exp(y(9))*(1+y(32));
residual(13)= lhs-rhs;
lhs =exp(y(12));
rhs =params(1)*exp(y(13))/exp(y(13))*T163;
residual(14)= lhs-rhs;
lhs =exp(y(13));
rhs =T169^(-1)-params(1)*params(43)*(exp(y(1))*exp(y(11))-exp(y(11))*params(43))^(-1);
residual(15)= lhs-rhs;
lhs =exp(y(42));
rhs =T185;
residual(16)= lhs-rhs;
lhs =exp(y(15));
rhs =exp(y(17))+T135*(1-params(4));
residual(17)= lhs-rhs;
lhs =exp(y(16));
rhs =1+y(28)+T195*y(29)-y(29)*exp(y(12))*T195^2;
residual(18)= lhs-rhs;
lhs =exp(y(16));
rhs =exp(y(12))*(T209+(1-params(4))*exp(y(16)));
residual(19)= lhs-rhs;
lhs =exp(y(20));
rhs =(exp(y(2))-1)*exp(y(5));
residual(20)= lhs-rhs;
lhs =y(28);
rhs =T217*(T195-params(32))^2;
residual(21)= lhs-rhs;
lhs =y(29);
rhs =params(14)*(T195-params(32));
residual(22)= lhs-rhs;
lhs =y(30);
rhs =T226*(T64-params(32))^2;
residual(23)= lhs-rhs;
lhs =y(31);
rhs =params(15)*(T64-params(32));
residual(24)= lhs-rhs;
lhs =y(32);
rhs =T234*(T104-params(32))^2;
residual(25)= lhs-rhs;
lhs =y(33);
rhs =params(16)*(T104-params(32));
residual(26)= lhs-rhs;
lhs =T242^(1-exp(y(38)));
rhs =params(26)*T253^(1-exp(y(38)))+(1-params(26))*exp(y(24))^(1-exp(y(38)));
residual(27)= lhs-rhs;
lhs =exp(y(24));
rhs =T271;
residual(28)= lhs-rhs;
lhs =exp(y(25));
rhs =exp(y(10))*1/exp(y(22))*exp(y(13))+exp(y(25))*T282*T283;
residual(29)= lhs-rhs;
lhs =exp(y(26));
rhs =exp(y(10))*exp(y(13))+exp(y(26))*T294*T295;
residual(30)= lhs-rhs;
lhs =1;
rhs =exp(y(12))*exp(y(27))/T242*exp(y(36));
residual(31)= lhs-rhs;
lhs =exp(y(27));
rhs =T309*T327^(1-params(24))*exp(y(37));
residual(32)= lhs-rhs;
lhs =exp(y(42))^(1-params(28));
rhs =(1-params(27))*exp(y(43))^(1-params(28))+params(27)*(params(32)*exp(y(42))*T163*T344*T352)^(1-params(28));
residual(33)= lhs-rhs;
lhs =exp(y(43));
rhs =T365;
residual(34)= lhs-rhs;
lhs =exp(y(44));
rhs =exp(y(13))*exp(y(46))*exp(y(47))+exp(y(44))*params(1)*params(27);
residual(35)= lhs-rhs;
lhs =exp(y(45));
rhs =exp(y(13))*exp(y(46))+exp(y(45))*T344*T352*params(32)*T163*params(1)*params(27);
residual(36)= lhs-rhs;
lhs =exp(y(46));
rhs =T387;
residual(37)= lhs-rhs;
lhs =exp(y(47));
rhs =params(5)*exp(y(46))^params(3)/exp(y(13));
residual(38)= lhs-rhs;
lhs =y(37);
rhs =y(37)*params(19)+params(18)*x(3);
residual(39)= lhs-rhs;
lhs =y(36);
rhs =y(36)*params(21)+params(20)*x(4);
residual(40)= lhs-rhs;
lhs =exp(y(38));
rhs =params(38)*exp(y(39));
residual(41)= lhs-rhs;
lhs =y(39);
rhs =y(39)*params(39)+params(40)*x(5);
residual(42)= lhs-rhs;
lhs =y(40);
rhs =y(40)*params(41)+params(42)*x(6);
residual(43)= lhs-rhs;
lhs =y(34);
rhs =y(34)*params(9)+params(10)*x(1);
residual(44)= lhs-rhs;
lhs =y(35);
rhs =y(35)*params(12)-params(13)*x(2);
residual(45)= lhs-rhs;
lhs =exp(y(49));
rhs =params(7)+params(7)*exp(y(50))*(exp(y(51))-1);
residual(46)= lhs-rhs;
lhs =exp(y(49))*exp(y(51));
rhs =params(7)*exp(y(51))+exp(y(52));
residual(47)= lhs-rhs;
lhs =exp(y(52));
rhs =T464;
residual(48)= lhs-rhs;
lhs =exp(y(55));
rhs =(-exp(y(56)))*exp(y(70))+params(7)*exp(y(57))*(exp(y(50))*exp(y(58))+exp(y(55))*(1-exp(y(50))));
residual(49)= lhs-rhs;
lhs =exp(y(70));
rhs =1+y(73)+T491*y(74)-y(74)*exp(y(57))*T491^2;
residual(50)= lhs-rhs;
lhs =exp(y(58));
rhs =exp(y(59))+params(7)*exp(y(57))*exp(y(58));
residual(51)= lhs-rhs;
lhs =exp(y(59));
rhs =T510;
residual(52)= lhs-rhs;
lhs =exp(y(34))*params(11)*exp(y(55))*exp(y(57));
rhs =T520;
residual(53)= lhs-rhs;
lhs =exp(y(71));
rhs =1+y(75)+T525*y(76)-y(76)*exp(y(57))*T525^2;
residual(54)= lhs-rhs;
lhs =T536*(exp(y(58))-exp(y(55)));
rhs =exp(y(70))*exp(y(56))^(1-params(31));
residual(55)= lhs-rhs;
lhs =exp(y(50));
rhs =params(30)*exp(y(53))^params(17)*exp(y(56))^params(31);
residual(56)= lhs-rhs;
lhs =exp(y(60));
rhs =T554;
residual(57)= lhs-rhs;
lhs =exp(y(60));
rhs =exp(y(65))+(1+y(63))*exp(y(66))+(1+y(73))*exp(y(72))+exp(y(53))*(1+y(75));
residual(58)= lhs-rhs;
lhs =exp(y(57));
rhs =params(1)*exp(y(67))/exp(y(67))*exp(y(49))^(-1);
residual(59)= lhs-rhs;
lhs =exp(y(67));
rhs =T578^(-1)-params(1)*params(43)*(exp(y(49))*exp(y(65))-params(43)*exp(y(65)))^(-1);
residual(60)= lhs-rhs;
lhs =exp(y(48));
rhs =T591;
residual(61)= lhs-rhs;
lhs =exp(y(54));
rhs =exp(y(66))+(1-params(4))*T548;
residual(62)= lhs-rhs;
lhs =exp(y(68));
rhs =1+y(63)+T599*y(62)-y(62)*exp(y(57))*T599^2;
residual(63)= lhs-rhs;
lhs =exp(y(68));
rhs =exp(y(57))*(T613+(1-params(4))*exp(y(68)));
residual(64)= lhs-rhs;
lhs =exp(y(72));
rhs =(exp(y(51))-1)*exp(y(56));
residual(65)= lhs-rhs;
lhs =y(63);
rhs =T217*(T599-params(32))^2;
residual(66)= lhs-rhs;
lhs =y(62);
rhs =params(14)*(T599-params(32));
residual(67)= lhs-rhs;
lhs =y(73);
rhs =T226*(T491-params(32))^2;
residual(68)= lhs-rhs;
lhs =y(74);
rhs =params(15)*(T491-params(32));
residual(69)= lhs-rhs;
lhs =y(75);
rhs =T234*(T525-params(32))^2;
residual(70)= lhs-rhs;
lhs =y(76);
rhs =params(16)*(T525-params(32));
residual(71)= lhs-rhs;
lhs =exp(y(61));
rhs =params(38)/(params(38)-1);
residual(72)= lhs-rhs;
lhs =1;
rhs =exp(y(36))*exp(y(57))*exp(y(69))/params(36);
residual(73)= lhs-rhs;
lhs =exp(y(48));
rhs =T649*1/exp(y(67));
residual(74)= lhs-rhs;
lhs =exp(y(41));
rhs =T654;
residual(75)= lhs-rhs;
lhs =exp(y(21));
rhs =exp(y(15))*exp(y(16))+exp(y(7))-exp(y(8))+(exp(y(2))-1)*(exp(y(6))+exp(y(5))*exp(y(18)));
residual(76)= lhs-rhs;
lhs =exp(y(77));
rhs =exp(y(6))*exp(y(12));
residual(77)= lhs-rhs;
lhs =exp(y(78));
rhs =exp(y(12))*(exp(y(7))-exp(y(6)));
residual(78)= lhs-rhs;
lhs =exp(y(79));
rhs =exp(y(27))/T242;
residual(79)= lhs-rhs;
if ~isreal(residual)
  residual = real(residual)+imag(residual).^2;
end
if nargout >= 2,
  g1 = zeros(79, 79);

  %
  % Jacobian matrix
  %

  g1(1,1)=exp(y(1));
  g1(1,2)=(-(params(7)*exp(y(3))*exp(y(2))));
  g1(1,3)=(-(params(7)*exp(y(3))*(exp(y(2))-1)));
  g1(2,1)=exp(y(1))*exp(y(2));
  g1(2,2)=exp(y(1))*exp(y(2))-params(7)*exp(y(2));
  g1(2,4)=(-exp(y(4)));
  g1(3,2)=(-(exp(y(9))^params(8)*params(11)*exp(y(34))*exp(y(2))*getPowerDeriv(exp(y(2)),1-params(8),1)));
  g1(3,4)=exp(y(4));
  g1(3,9)=(-(params(11)*exp(y(34))*exp(y(2))^(1-params(8))*exp(y(9))*getPowerDeriv(exp(y(9)),params(8),1)));
  g1(3,34)=(-T37);
  g1(4,3)=(-(params(7)*exp(y(12))*(exp(y(3))*exp(y(7))+exp(y(6))*(-exp(y(3))))));
  g1(4,5)=(-((-exp(y(5)))*exp(y(18))));
  g1(4,6)=exp(y(6))-params(7)*exp(y(12))*exp(y(6))*(1-exp(y(3)));
  g1(4,7)=(-(params(7)*exp(y(12))*exp(y(3))*exp(y(7))));
  g1(4,12)=(-(params(7)*exp(y(12))*(exp(y(3))*exp(y(7))+exp(y(6))*(1-exp(y(3))))));
  g1(4,18)=(-((-exp(y(5)))*exp(y(18))));
  g1(5,1)=(-(T64*y(31)-y(31)*exp(y(12))*T64*2*T64));
  g1(5,12)=y(31)*exp(y(12))*T64^2;
  g1(5,18)=exp(y(18));
  g1(5,30)=(-1);
  g1(5,31)=(-(T64-exp(y(12))*T64^2));
  g1(6,7)=exp(y(7))-params(7)*exp(y(12))*exp(y(7));
  g1(6,8)=(-exp(y(8)));
  g1(6,12)=(-(params(7)*exp(y(12))*exp(y(7))));
  g1(7,8)=exp(y(8));
  g1(7,10)=(-T87);
  g1(7,22)=(-(exp(y(10))*T80*T903));
  g1(8,2)=(-(exp(y(19))*exp(y(35))*(-(exp(y(2))*exp(y(9))))/(exp(y(2))*exp(y(2)))*getPowerDeriv(T92,1-params(8),1)));
  g1(8,6)=exp(y(34))*params(11)*exp(y(6))*exp(y(12));
  g1(8,9)=(-(exp(y(19))*exp(y(35))*T92*getPowerDeriv(T92,1-params(8),1)));
  g1(8,12)=exp(y(34))*params(11)*exp(y(6))*exp(y(12));
  g1(8,19)=T897;
  g1(8,34)=exp(y(34))*params(11)*exp(y(6))*exp(y(12));
  g1(8,35)=T897;
  g1(9,1)=(-(T104*y(33)-y(33)*exp(y(12))*T104*2*T104));
  g1(9,12)=y(33)*exp(y(12))*T104^2;
  g1(9,19)=exp(y(19));
  g1(9,32)=(-1);
  g1(9,33)=(-(T104-exp(y(12))*T104^2));
  g1(10,5)=(-(exp(y(18))*exp(y(5))*getPowerDeriv(exp(y(5)),1-params(31),1)));
  g1(10,6)=T120*(-exp(y(6)));
  g1(10,7)=exp(y(7))*T120;
  g1(10,9)=(exp(y(7))-exp(y(6)))*exp(y(12))*params(7)*params(31)*params(30)*exp(y(9))*getPowerDeriv(exp(y(9)),params(17),1);
  g1(10,12)=T120*(exp(y(7))-exp(y(6)));
  g1(10,18)=(-(exp(y(18))*exp(y(5))^(1-params(31))));
  g1(11,3)=exp(y(3));
  g1(11,5)=(-(params(30)*exp(y(9))^params(17)*exp(y(5))*getPowerDeriv(exp(y(5)),params(31),1)));
  g1(11,9)=(-(exp(y(5))^params(31)*params(30)*exp(y(9))*getPowerDeriv(exp(y(9)),params(17),1)));
  g1(12,1)=(-(T142*exp(y(40))*T692*getPowerDeriv(T135,params(2),1)));
  g1(12,10)=exp(y(10));
  g1(12,14)=(-(exp(y(40))*T135^params(2)*exp(y(14))*getPowerDeriv(exp(y(14)),1-params(2),1)));
  g1(12,15)=(-(T142*exp(y(40))*T135*getPowerDeriv(T135,params(2),1)));
  g1(12,40)=(-(exp(y(40))*T135^params(2)*T142));
  g1(13,9)=(-(exp(y(9))*(1+y(32))));
  g1(13,10)=exp(y(10));
  g1(13,11)=(-exp(y(11)));
  g1(13,17)=(-((1+y(28))*exp(y(17))));
  g1(13,20)=(-((1+y(30))*exp(y(20))));
  g1(13,28)=(-exp(y(17)));
  g1(13,30)=(-exp(y(20)));
  g1(13,32)=(-exp(y(9)));
  g1(14,1)=(-(params(1)*exp(y(13))/exp(y(13))*T699));
  g1(14,12)=exp(y(12));
  g1(15,1)=(-((-((-(exp(y(1))*exp(y(11))*params(43)))/(exp(y(1))*exp(y(1)))))*getPowerDeriv(T169,(-1),1)-params(1)*params(43)*exp(y(1))*exp(y(11))*T708));
  g1(15,11)=(-(T169*getPowerDeriv(T169,(-1),1)-params(1)*params(43)*(exp(y(1))*exp(y(11))-exp(y(11))*params(43))*T708));
  g1(15,13)=exp(y(13));
  g1(16,10)=(-T185);
  g1(16,14)=(-(T183*(-(exp(y(10))*exp(y(14))))/(exp(y(14))*exp(y(14)))));
  g1(16,22)=(-(exp(y(10))/exp(y(14))*(1-params(2))*T181*T903));
  g1(16,42)=exp(y(42));
  g1(17,1)=(-((1-params(4))*T692));
  g1(17,15)=exp(y(15))-T135*(1-params(4));
  g1(17,17)=(-exp(y(17)));
  g1(18,1)=(-(T195*y(29)-y(29)*exp(y(12))*T195*2*T195));
  g1(18,12)=y(29)*exp(y(12))*T195^2;
  g1(18,16)=exp(y(16));
  g1(18,28)=(-1);
  g1(18,29)=(-(T195-exp(y(12))*T195^2));
  g1(19,1)=(-(exp(y(12))*T209));
  g1(19,10)=(-(exp(y(12))*T209));
  g1(19,12)=(-(exp(y(12))*(T209+(1-params(4))*exp(y(16)))));
  g1(19,15)=T888;
  g1(19,16)=exp(y(16))-exp(y(12))*(1-params(4))*exp(y(16));
  g1(19,22)=T888;
  g1(20,2)=(-(exp(y(2))*exp(y(5))));
  g1(20,5)=(-((exp(y(2))-1)*exp(y(5))));
  g1(20,20)=exp(y(20));
  g1(21,1)=(-(T217*T195*2*(T195-params(32))));
  g1(21,28)=1;
  g1(22,1)=(-(T195*params(14)));
  g1(22,29)=1;
  g1(23,1)=(-(T226*T64*2*(T64-params(32))));
  g1(23,30)=1;
  g1(24,1)=(-(T64*params(15)));
  g1(24,31)=1;
  g1(25,1)=(-(T234*T104*2*(T104-params(32))));
  g1(25,32)=1;
  g1(26,1)=(-(T104*params(16)));
  g1(26,33)=1;
  g1(27,23)=T242*getPowerDeriv(T242,1-exp(y(38)),1)-params(26)*params(36)^(1-params(37))*T242*getPowerDeriv(T242,params(37),1)*getPowerDeriv(T253,1-exp(y(38)),1);
  g1(27,24)=(-((1-params(26))*exp(y(24))*getPowerDeriv(exp(y(24)),1-exp(y(38)),1)));
  g1(27,38)=T242^(1-exp(y(38)))*(-exp(y(38)))*log(T242)-(params(26)*T253^(1-exp(y(38)))*(-exp(y(38)))*log(T253)+(1-params(26))*exp(y(24))^(1-exp(y(38)))*(-exp(y(38)))*log(exp(y(24))));
  g1(28,23)=(-T271);
  g1(28,24)=exp(y(24));
  g1(28,25)=(-T271);
  g1(28,26)=(-(T242*exp(y(38))/(exp(y(38))-1)*(-(exp(y(25))*exp(y(26))))/(exp(y(26))*exp(y(26)))));
  g1(28,38)=(-(T242*exp(y(25))/exp(y(26))*(exp(y(38))*(exp(y(38))-1)-exp(y(38))*exp(y(38)))/((exp(y(38))-1)*(exp(y(38))-1))));
  g1(29,10)=(-(exp(y(10))*1/exp(y(22))*exp(y(13))));
  g1(29,13)=(-(exp(y(10))*1/exp(y(22))*exp(y(13))));
  g1(29,22)=(-(exp(y(10))*exp(y(13))*T903));
  g1(29,23)=(-(exp(y(25))*(T283*T281*params(1)*params(26)*T242*getPowerDeriv(T242,params(37)*(-exp(y(38))),1)+T282*T242*getPowerDeriv(T242,exp(y(38)),1))));
  g1(29,25)=exp(y(25))-exp(y(25))*T282*T283;
  g1(29,38)=(-(exp(y(25))*(T283*(T281*params(1)*params(26)*T242^(params(37)*(-exp(y(38))))*params(37)*(-exp(y(38)))*log(T242)+params(1)*params(26)*T242^(params(37)*(-exp(y(38))))*T281*(1-params(37))*(-exp(y(38)))*log(params(36)))+T282*T283*exp(y(38))*log(T242))));
  g1(30,10)=(-(exp(y(10))*exp(y(13))));
  g1(30,13)=(-(exp(y(10))*exp(y(13))));
  g1(30,23)=(-(exp(y(26))*(T295*T293*params(1)*params(26)*T242*getPowerDeriv(T242,(1-exp(y(38)))*params(37),1)+T294*T242*getPowerDeriv(T242,exp(y(38))-1,1))));
  g1(30,26)=exp(y(26))-exp(y(26))*T294*T295;
  g1(30,38)=(-(exp(y(26))*(T295*(T293*params(1)*params(26)*T242^((1-exp(y(38)))*params(37))*params(37)*(-exp(y(38)))*log(T242)+params(1)*params(26)*T242^((1-exp(y(38)))*params(37))*T293*(1-params(37))*(-exp(y(38)))*log(params(36)))+T294*T295*exp(y(38))*log(T242))));
  g1(31,12)=T857;
  g1(31,23)=(-(exp(y(36))*(-(T242*exp(y(12))*exp(y(27))))/(T242*T242)));
  g1(31,27)=T857;
  g1(31,36)=T857;
  g1(32,10)=(-(exp(y(37))*T309*params(36)*T312*T320*getPowerDeriv(T320,params(23),1)/T326*T840));
  g1(32,23)=(-(exp(y(37))*T309*T840*params(36)*T320^params(23)*T242/params(36)*getPowerDeriv(T242/params(36),params(22),1)/T326));
  g1(32,27)=exp(y(27))-exp(y(37))*T327^(1-params(24))*exp(y(27))*getPowerDeriv(exp(y(27)),params(24),1);
  g1(32,37)=(-(T309*T327^(1-params(24))*exp(y(37))));
  g1(32,41)=(-(exp(y(37))*T309*T840*params(36)*T312*getPowerDeriv(T320,params(23),1)*exp(y(10))*exp(y(41))*getPowerDeriv(exp(y(41)),params(25),1)/exp(y(60))/T326));
  g1(32,60)=(-(exp(y(37))*T309*T840*params(36)*T312*getPowerDeriv(T320,params(23),1)*(-(exp(y(10))*exp(y(41))^params(25)*exp(y(60))))/(exp(y(60))*exp(y(60)))/T326));
  g1(33,1)=(-(params(27)*T352*params(32)*exp(y(42))*T344*T699*T745));
  g1(33,23)=(-(params(27)*T745*(T352*params(32)*exp(y(42))*T163*T242*getPowerDeriv(T242,(-1),1)+params(32)*exp(y(42))*T163*T344*T968)));
  g1(33,42)=exp(y(42))*getPowerDeriv(exp(y(42)),1-params(28),1)-params(27)*params(32)*exp(y(42))*T163*T344*T352*T745;
  g1(33,43)=(-((1-params(27))*exp(y(43))*getPowerDeriv(exp(y(43)),1-params(28),1)));
  g1(34,43)=exp(y(43));
  g1(34,44)=(-T365);
  g1(34,45)=(-((-(params(28)/(params(28)-1)*exp(y(44))*exp(y(45))))/(exp(y(45))*exp(y(45)))));
  g1(35,13)=(-(exp(y(13))*exp(y(46))*exp(y(47))));
  g1(35,44)=exp(y(44))-exp(y(44))*params(1)*params(27);
  g1(35,46)=(-(exp(y(13))*exp(y(46))*exp(y(47))));
  g1(35,47)=(-(exp(y(13))*exp(y(46))*exp(y(47))));
  g1(36,1)=(-(exp(y(45))*T344*T352*params(32)*params(1)*params(27)*T699));
  g1(36,13)=(-(exp(y(13))*exp(y(46))));
  g1(36,23)=(-(exp(y(45))*(T352*params(32)*T163*params(1)*params(27)*T242*getPowerDeriv(T242,(-1),1)+T344*params(32)*T163*params(1)*params(27)*T968)));
  g1(36,45)=exp(y(45))-exp(y(45))*T344*T352*params(32)*T163*params(1)*params(27);
  g1(36,46)=(-(exp(y(13))*exp(y(46))));
  g1(37,14)=(-T387);
  g1(37,42)=(-(exp(y(14))*(-(exp(y(42))*exp(y(43))))/(exp(y(42))*exp(y(42)))*getPowerDeriv(T384,(-params(28)),1)));
  g1(37,43)=(-(exp(y(14))*T384*getPowerDeriv(T384,(-params(28)),1)));
  g1(37,46)=exp(y(46));
  g1(38,13)=(-((-(exp(y(13))*params(5)*exp(y(46))^params(3)))/(exp(y(13))*exp(y(13)))));
  g1(38,46)=(-(params(5)*exp(y(46))*getPowerDeriv(exp(y(46)),params(3),1)/exp(y(13))));
  g1(38,47)=exp(y(47));
  g1(39,37)=1-params(19);
  g1(40,36)=1-params(21);
  g1(41,38)=exp(y(38));
  g1(41,39)=(-(params(38)*exp(y(39))));
  g1(42,39)=1-params(39);
  g1(43,40)=1-params(41);
  g1(44,34)=1-params(9);
  g1(45,35)=1-params(12);
  g1(46,49)=exp(y(49));
  g1(46,50)=(-(params(7)*exp(y(50))*(exp(y(51))-1)));
  g1(46,51)=(-(params(7)*exp(y(50))*exp(y(51))));
  g1(47,49)=exp(y(49))*exp(y(51));
  g1(47,51)=exp(y(49))*exp(y(51))-params(7)*exp(y(51));
  g1(47,52)=(-exp(y(52)));
  g1(48,34)=(-T464);
  g1(48,51)=(-(exp(y(53))^params(8)*params(11)*exp(y(34))*exp(y(51))*getPowerDeriv(exp(y(51)),1-params(8),1)));
  g1(48,52)=exp(y(52));
  g1(48,53)=(-(params(11)*exp(y(34))*exp(y(51))^(1-params(8))*exp(y(53))*getPowerDeriv(exp(y(53)),params(8),1)));
  g1(49,50)=(-(params(7)*exp(y(57))*(exp(y(50))*exp(y(58))+exp(y(55))*(-exp(y(50))))));
  g1(49,55)=exp(y(55))-params(7)*exp(y(57))*exp(y(55))*(1-exp(y(50)));
  g1(49,56)=(-((-exp(y(56)))*exp(y(70))));
  g1(49,57)=(-(params(7)*exp(y(57))*(exp(y(50))*exp(y(58))+exp(y(55))*(1-exp(y(50))))));
  g1(49,58)=(-(params(7)*exp(y(57))*exp(y(50))*exp(y(58))));
  g1(49,70)=(-((-exp(y(56)))*exp(y(70))));
  g1(50,49)=(-(T491*y(74)-y(74)*exp(y(57))*T491*2*T491));
  g1(50,57)=y(74)*exp(y(57))*T491^2;
  g1(50,70)=exp(y(70));
  g1(50,73)=(-1);
  g1(50,74)=(-(T491-exp(y(57))*T491^2));
  g1(51,57)=(-(params(7)*exp(y(57))*exp(y(58))));
  g1(51,58)=exp(y(58))-params(7)*exp(y(57))*exp(y(58));
  g1(51,59)=(-exp(y(59)));
  g1(52,59)=exp(y(59));
  g1(52,60)=(-T510);
  g1(52,61)=(-(exp(y(60))*T80*(-exp(y(61)))/(exp(y(61))*exp(y(61)))));
  g1(53,34)=exp(y(34))*params(11)*exp(y(55))*exp(y(57));
  g1(53,35)=(-T520);
  g1(53,51)=(-(exp(y(71))*exp(y(35))*(-(exp(y(51))*exp(y(53))))/(exp(y(51))*exp(y(51)))*getPowerDeriv(T515,1-params(8),1)));
  g1(53,53)=(-(exp(y(71))*exp(y(35))*T515*getPowerDeriv(T515,1-params(8),1)));
  g1(53,55)=exp(y(34))*params(11)*exp(y(55))*exp(y(57));
  g1(53,57)=exp(y(34))*params(11)*exp(y(55))*exp(y(57));
  g1(53,71)=(-T520);
  g1(54,49)=(-(T525*y(76)-y(76)*exp(y(57))*T525*2*T525));
  g1(54,57)=y(76)*exp(y(57))*T525^2;
  g1(54,71)=exp(y(71));
  g1(54,75)=(-1);
  g1(54,76)=(-(T525-exp(y(57))*T525^2));
  g1(55,53)=(exp(y(58))-exp(y(55)))*exp(y(57))*params(7)*params(31)*params(30)*exp(y(53))*getPowerDeriv(exp(y(53)),params(17),1);
  g1(55,55)=T536*(-exp(y(55)));
  g1(55,56)=(-(exp(y(70))*exp(y(56))*getPowerDeriv(exp(y(56)),1-params(31),1)));
  g1(55,57)=T536*(exp(y(58))-exp(y(55)));
  g1(55,58)=exp(y(58))*T536;
  g1(55,70)=(-(exp(y(70))*exp(y(56))^(1-params(31))));
  g1(56,50)=exp(y(50));
  g1(56,53)=(-(exp(y(56))^params(31)*params(30)*exp(y(53))*getPowerDeriv(exp(y(53)),params(17),1)));
  g1(56,56)=(-(params(30)*exp(y(53))^params(17)*exp(y(56))*getPowerDeriv(exp(y(56)),params(31),1)));
  g1(57,40)=(-T554);
  g1(57,49)=(-(T553*exp(y(40))*T1136*getPowerDeriv(T548,params(2),1)));
  g1(57,54)=(-(T553*exp(y(40))*T548*getPowerDeriv(T548,params(2),1)));
  g1(57,60)=exp(y(60));
  g1(57,64)=(-(exp(y(40))*T548^params(2)*exp(y(64))*getPowerDeriv(exp(y(64)),1-params(2),1)));
  g1(58,53)=(-(exp(y(53))*(1+y(75))));
  g1(58,60)=exp(y(60));
  g1(58,63)=(-exp(y(66)));
  g1(58,65)=(-exp(y(65)));
  g1(58,66)=(-((1+y(63))*exp(y(66))));
  g1(58,72)=(-((1+y(73))*exp(y(72))));
  g1(58,73)=(-exp(y(72)));
  g1(58,75)=(-exp(y(53)));
  g1(59,49)=(-(params(1)*exp(y(67))/exp(y(67))*exp(y(49))*getPowerDeriv(exp(y(49)),(-1),1)));
  g1(59,57)=exp(y(57));
  g1(60,49)=(-((-((-(exp(y(49))*params(43)*exp(y(65))))/(exp(y(49))*exp(y(49)))))*getPowerDeriv(T578,(-1),1)-params(1)*params(43)*exp(y(49))*exp(y(65))*T1152));
  g1(60,65)=(-(T578*getPowerDeriv(T578,(-1),1)-params(1)*params(43)*(exp(y(49))*exp(y(65))-params(43)*exp(y(65)))*T1152));
  g1(60,67)=exp(y(67));
  g1(61,48)=exp(y(48));
  g1(61,60)=(-T591);
  g1(61,61)=(-(exp(y(60))/exp(y(64))*(1-params(2))*T181*(-exp(y(61)))/(exp(y(61))*exp(y(61)))));
  g1(61,64)=(-((1-params(2))*T181*1/exp(y(61))*(-(exp(y(60))*exp(y(64))))/(exp(y(64))*exp(y(64)))));
  g1(62,49)=(-((1-params(4))*T1136));
  g1(62,54)=exp(y(54))-(1-params(4))*T548;
  g1(62,66)=(-exp(y(66)));
  g1(63,49)=(-(T599*y(62)-y(62)*exp(y(57))*T599*2*T599));
  g1(63,57)=y(62)*exp(y(57))*T599^2;
  g1(63,62)=(-(T599-exp(y(57))*T599^2));
  g1(63,63)=(-1);
  g1(63,68)=exp(y(68));
  g1(64,49)=(-(exp(y(57))*T613));
  g1(64,54)=T1244;
  g1(64,57)=(-(exp(y(57))*(T613+(1-params(4))*exp(y(68)))));
  g1(64,60)=(-(exp(y(57))*T613));
  g1(64,61)=T1244;
  g1(64,68)=exp(y(68))-exp(y(57))*(1-params(4))*exp(y(68));
  g1(65,51)=(-(exp(y(51))*exp(y(56))));
  g1(65,56)=(-((exp(y(51))-1)*exp(y(56))));
  g1(65,72)=exp(y(72));
  g1(66,49)=(-(T217*T599*2*(T599-params(32))));
  g1(66,63)=1;
  g1(67,49)=(-(params(14)*T599));
  g1(67,62)=1;
  g1(68,49)=(-(T226*T491*2*(T491-params(32))));
  g1(68,73)=1;
  g1(69,49)=(-(params(15)*T491));
  g1(69,74)=1;
  g1(70,49)=(-(T234*T525*2*(T525-params(32))));
  g1(70,75)=1;
  g1(71,49)=(-(params(16)*T525));
  g1(71,76)=1;
  g1(72,61)=exp(y(61));
  g1(73,36)=T1018;
  g1(73,57)=T1018;
  g1(73,69)=T1018;
  g1(74,48)=exp(y(48));
  g1(74,64)=(-(1/exp(y(67))*params(28)/(params(28)-1)*params(5)*exp(y(64))*getPowerDeriv(exp(y(64)),params(3),1)));
  g1(74,67)=(-(T649*(-exp(y(67)))/(exp(y(67))*exp(y(67)))));
  g1(75,1)=(-T654);
  g1(75,41)=exp(y(41))-T654;
  g1(75,49)=(-((-(exp(y(49))*exp(y(1))*exp(y(41))))/(exp(y(49))*exp(y(49)))));
  g1(76,2)=(-(exp(y(2))*(exp(y(6))+exp(y(5))*exp(y(18)))));
  g1(76,5)=(-((exp(y(2))-1)*exp(y(5))*exp(y(18))));
  g1(76,6)=(-((exp(y(2))-1)*exp(y(6))));
  g1(76,7)=(-exp(y(7)));
  g1(76,8)=exp(y(8));
  g1(76,15)=(-(exp(y(15))*exp(y(16))));
  g1(76,16)=(-(exp(y(15))*exp(y(16))));
  g1(76,18)=(-((exp(y(2))-1)*exp(y(5))*exp(y(18))));
  g1(76,21)=exp(y(21));
  g1(77,6)=(-(exp(y(6))*exp(y(12))));
  g1(77,12)=(-(exp(y(6))*exp(y(12))));
  g1(77,77)=exp(y(77));
  g1(78,6)=(-(exp(y(12))*(-exp(y(6)))));
  g1(78,7)=(-(exp(y(12))*exp(y(7))));
  g1(78,12)=(-(exp(y(12))*(exp(y(7))-exp(y(6)))));
  g1(78,78)=exp(y(78));
  g1(79,23)=(-((-(T242*exp(y(27))))/(T242*T242)));
  g1(79,27)=(-(exp(y(27))/T242));
  g1(79,79)=exp(y(79));
  if ~isreal(g1)
    g1 = real(g1)+2*imag(g1);
  end
end
if nargout >= 3,
  %
  % Hessian matrix
  %

  g2 = sparse([],[],[],79,6241);
end
end
